/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/1/19
 * \* Time: 15:59
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class TestDemo {
    public static void main(String[] args) {
        BinayTree binayTree = new BinayTree();
        TreeNode root = binayTree.creatTree();
        System.out.println("========前序遍历============");
        binayTree.preOrder(root);
        System.out.println();
        System.out.println("========中序遍历============");
        binayTree.inOrder(root);
        System.out.println();
        System.out.println("========后续遍历============");
        binayTree.postOrder(root);
        System.out.println();
        System.out.println("========树中节点个数==========");
        System.out.println(binayTree.size(root));
        System.out.println();
        System.out.println("========叶子节点的个数==========");
        System.out.println(binayTree.getLeafNodeCount(root));
        System.out.println();
        System.out.println("========求第k层节点的个数===========");
        System.out.println(binayTree.getKLevelNodeCount(root,2));
        System.out.println("=====查找节点=======");
        try {
            TreeNode ret = BinayTree.find(root,'E');
            System.out.println(ret.val);
        }catch (NullPointerException e) {
            e.printStackTrace();
            System.out.println("没有这个节点！");
        }

    }
}
